//
//  FaceView.m
//  30203
//
//  Created by student on 16/4/6.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "FaceView.h"

@implementation FaceView
-(void)setHappy:(int)happy
{
    _happy=happy;
    [self setNeedsLayout];
}
-(void)drawRect:(CGRect)rect
{
    [self drawface];
    [self draweyes1];
    [self draweyes2];
}
-(void)drawface
{
    UIBezierPath *path=[UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(187, 323)];
    [path addArcWithCenter:CGPointMake(187, 323) radius:150 startAngle:0 endAngle:M_PI*2 clockwise:YES];
    [[UIColor whiteColor] setFill];
    path.lineWidth=5;
    [path stroke];
    [path fill];
}
-(void)draweyes1
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(ctx, 62, 323);
    CGContextAddQuadCurveToPoint(ctx, 112, 250, 162, 323);
    [[UIColor blackColor] setStroke];
    CGContextStrokePath(ctx);
}
-(void)draweyes2
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(ctx, 212, 323);
    CGContextAddQuadCurveToPoint(ctx, 272, 250, 312, 323);
    [[UIColor blackColor] setStroke];
    CGContextStrokePath(ctx);
}
-(void)drawmouth:(int)happy
{
    CGContextRef ctx=UIGraphicsGetCurrentContext();
    CGContextMoveToPoint(ctx, 112, 400);
    CGContextAddQuadCurveToPoint(ctx, 187, happy, 272, 400);
    [[UIColor blackColor] setStroke];
    CGContextStrokePath(ctx);

}
@end
